#include <iostream>
#include <cstring>

class Car
{
public:
    Car(std::string type, std::string brand, int maxspeed) : m_nowspeed(0)
    {
        m_type = type;
        m_brand = brand;
        m_maxspeed = maxspeed;
    }

    void accelerate(int value);
    void brake(int value);
    void display();

   

private:
    int m_maxspeed;
    int m_nowspeed;
    std::string m_brand;
    std::string m_type;
};

void Car::accelerate(int value)
{
    m_nowspeed = m_nowspeed + value;

    if (m_nowspeed > m_maxspeed)

    {
        m_nowspeed = m_nowspeed - value;

        std::cout << "加不了了" << std::endl;
    }
}

void Car::brake(int value)
{
    m_nowspeed = m_nowspeed - value;

    if (m_nowspeed < 0)
    {
        m_nowspeed = m_nowspeed + value;

        std::cout << "不能再减速了" << std::endl;
    }
}

void Car::display()
{
    std::cout << "品牌是" << m_type << std::endl;
    std::cout << "型号是" << m_brand << std::endl;
    std::cout << "最大速度是" << m_maxspeed << std::endl;
    std::cout << "当前速度是" << m_nowspeed << std::endl;
    std::cout<<std::endl;
}



int main()
{

    Car f("Farrari", "F12", 340);

    f.display();

    f.accelerate(300);
    f.display();

    return 0;
}